package com.beigai.imessage.server;

import com.beigai.imessage.client.dto.IPAddress;
import com.beigai.imessage.user.dto.UserFriend;

import java.io.Serializable;
import java.util.Map;

/**
 * Created by xxl on 2017/5/10.
 */
public class UserSession extends UserSessionAbs implements Serializable {
    private Map<String,UserFriend> friends;
    private IPAddress ipAddress;
    private String code;
    private String nickname;


    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public UserSession(Mediator mediator) {
        super(mediator);
    }

    public void getMessage(SessionMessage sessionMessage) {
        friends.get(sessionMessage.getCode()).setOnline(sessionMessage.isOnline());
    }

    public void contact(SessionMessage sessionMessage) {
        mediator.contact(sessionMessage, this);
    }

    public Map<String, UserFriend> getFriends() {
        return friends;
    }

    public void setFriends(Map<String, UserFriend> friends) {
        this.friends = friends;
    }

    public IPAddress getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(IPAddress ipAddress) {
        this.ipAddress = ipAddress;
    }
}
